import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:yt_devops/components/gaps.dart';
import 'package:yt_devops/components/yt_text_style.dart';
import 'package:yt_devops/pages/site/site_setting/siet_elec_price_setting/add_mains_electricity_price/views/effective_data_widget.dart';
import 'package:yt_devops/resources/str_res_keys.dart';
import 'package:yt_devops/styles/styles.dart';


class PhotoVoltaicWidget extends StatelessWidget {
  final BuildContext context;
  final String title;
  final String startTime;
  final String endTime;
  final String priceString;
  final bool isDelete;
  final Function(String startDateTime,String endDateTime) timeChooseCallBack;
  final Function() btnClickCallBack;
  final Function(String str) textChangeCallBack;
  const PhotoVoltaicWidget(this.context,this.title,this.startTime,this.endTime,this.priceString,this.timeChooseCallBack,
      this.btnClickCallBack,this.textChangeCallBack,{this.isDelete = false,Key? key}) : super(key: key);


  @override
  Widget build(BuildContext context) {
    GetStorage storage = GetStorage();
    String monetaryUnitName = storage.read('monetaryUnitName')??'元';
    if(monetaryUnitName == '元' || monetaryUnitName == '¥'){
      monetaryUnitName = ResKey.yuan.tr;
    }
    TextEditingController textFieldController = TextEditingController();
    textFieldController.text = priceString;
    return SizedBox(
      height: 103,
      child: Column(
        children: [
          Gaps.vGap5,
          EffectiveDataWidget(context,title,
            startTime,
            endTime,(startDateTime,endDateTime){
              timeChooseCallBack(startDateTime,endDateTime);
            },(){
              btnClickCallBack();
            },isShowHour: true,isDelete: isDelete,isEdit: true,),

          Container(

            child: Row(
              children: [
                Gaps.hGap16,
                Container(
                  width: 90.w,
                  child: Text(
                    ResKey.siteSettingElectricityElectrovalency.tr,
                    style: ytTextStyle(
                        fontWeight: FontWeight.normal,
                        color: Colour.otherTextColor,
                        fontSize: 14),
                  ),
                ),
                // Spacer(),
               Container(
                 // margin: EdgeInsets.only(left: 10.w),
                      decoration: const BoxDecoration(
                          color: Colour.backgroundColor,
                          borderRadius: BorderRadius.all(Radius.circular(4))),
                      height: 32,
                      width: 106.w - 15.w,
                      alignment: Alignment.center,
                      child: TextField(
                        textAlign: TextAlign.center,
                        style: const TextStyle(
                            fontSize: 14, color: Colour.mainTextColor),
                        controller: textFieldController,
                        keyboardType: const TextInputType.numberWithOptions(decimal: true),
                        decoration:  InputDecoration(
                          border: InputBorder.none,
                          contentPadding:
                          const EdgeInsets.only(bottom: 13),
                          hintText: ResKey.siteSettingElectricityElectrovalency.tr,
                          enabled: true,
                          hintStyle: const TextStyle(
                              fontSize: 14.0,
                              color: Colour.lightTextColor,
                              fontWeight: FontWeight.normal),
                        ),
                        onChanged: (String str) {
                            textChangeCallBack(str);
                        },
                      ),
                    ),
                Container(
                  padding: EdgeInsets.only(left: 10.w),
                  // width: 169.w,
                  child:  Text(
                    '$monetaryUnitName/kWh',
                    style: ytTextStyle(
                        fontWeight: FontWeight.normal,
                        fontSize: 14),
                  ),
                )
              ],
            ),
          ),
          Spacer(),
          // Container(
          //   height: 1,
          //   // margin: EdgeInsets.only(left: 16.w, right: 16.w),
          //   color: Colour.dividerColor,
          // ),
        ],
      ),


    );
  }
}
